function parseInt() {
  // 转换单位
  function pointToMM(numIn) {
    return (numIn / 72) * 25.4;
  }
  function MMTopoint(numIn) {
    return (numIn / 25.4) * 72;
  }
  // 格式化数字
  function formatNumForOutput(numIn) {
    return parseFloat(trimEndZero(formatNum(numIn, 2)));
  }
  if (documents.length > 0) {
    var activeDocument = app.activeDocument;
    var elementsSelected = activeDocument.selection;
    if (elementsSelected.length > 0) {
      for (i = 0; i < elementsSelected.length; i++) {
        var targetItem = elementsSelected[i];
        var orginalFillColor = targetItem.fillColor;
        var orginalStrokeColor = targetItem.strokeColor;
        
        // 自动判断文档颜色模式
        // 由文档的颜色模式决定颜色的哪些属性可以读取。比如CMYK才有cyan属性。
        var docColorMode = 1;
        if (orginalFillColor.cyan == undefined && orginalStrokeColor.cyan == undefined) {
          docColorMode = 0;
        }

        if (docColorMode == 0) {
          alert("当前颜色模式为RGB, 或选中物体没有颜色需要转换!");
          return;
        }

        // 判断填充和描边颜色是否存在
        var fillExist = true;
        var strokeExist = true;

        if (orginalFillColor.cyan == undefined) {
          fillExist = false;
        }
        if (orginalStrokeColor.cyan == undefined) {
          strokeExist = false;
        }

        // 转换颜色
        if (fillExist) {
          var newFillColor = new CMYKColor();
          newFillColor.cyan = orginalFillColor.cyan.toFixed();
          newFillColor.magenta = orginalFillColor.magenta.toFixed();
          newFillColor.yellow = orginalFillColor.yellow.toFixed();
          newFillColor.black = orginalFillColor.black.toFixed();

          // 更新颜色
          targetItem.fillColor = newFillColor;
        }

        if (strokeExist) {
          var newStrokeColor = new CMYKColor();
          newStrokeColor.cyan = orginalStrokeColor.cyan.toFixed();
          newStrokeColor.magenta = orginalStrokeColor.magenta.toFixed();
          newStrokeColor.yellow = orginalStrokeColor.yellow.toFixed();
          newStrokeColor.black = orginalStrokeColor.black.toFixed();

          // 更新颜色
          targetItem.strokeColor = newStrokeColor;
        }

        // 重绘
        redraw();

        targetItem.selected = false;
      }
    } else {
      alert("请先选中一个物体!");
    }
  } else {
    alert("请先打开一个文档!");
  }
}

function formatNum(numIn, accuracyIn) {
  var tempNum = numIn.toFixed(accuracyIn + 2).slice(0, -1);
  var tempNumString = "" + tempNum;
  var lastNum = parseInt(tempNumString.charAt(tempNumString.length - 1));
  if (lastNum != 0) {
    var zeroString = "";
    var tempString = "";
    for (k = 1; k < accuracyIn; k++) {
      zeroString += "0";
    }
    tempString = "0." + zeroString + "1";
    // 此时area为字符串
    numIn = numIn.toFixed(accuracyIn + 1).slice(0, -1);
    numIn = parseFloat(numIn) + parseFloat(tempString);
  } else {
    numIn = numIn.toFixed(accuracyIn + 1).slice(0, -1);
  }
  return numIn;
}

function trimEndZero(numIn) {
  var originString = "" + numIn;
  numIn = parseFloat(originString);
  return numIn;
}
